<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>UMD Room Finder</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <script type="text/javascript">

        function getRooms(building){

            if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
              xmlhttp=new XMLHttpRequest();
              }
            else
              {// code for IE6, IE5
              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
            xmlhttp.onreadystatechange=function()
              {
              if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                document.getElementById("buildingDiv").innerHTML=xmlhttp.responseText;
                }
              }
            xmlhttp.open("GET","updateRooms2.php?Building="+building,true);
            xmlhttp.send();
        };


        getRooms("Heller Hall");
</script>

  </head>
  <body>

<style type="text/css">
body
{
background-color:#e5f5ff;
background-image:url(http://img.photobucket.com/albums/v627/lovkurama/Screenshot2011-10-03at53227PM.png);
background-repeat:repeat-x;
font-size: 1em;
}
#inhalt{
	text-align: center;;
	vertical-align: middle;
	margin: 0px auto;
	padding: 0px;
	width: 40%;
	background-color: #e5f5ff;
	
	}
div.banner
{
text-align:center;
}
</style>

<div class="banner">

<img src="http://img.photobucket.com/albums/v627/lovkurama/Screenshot2011-10-11at103904AM.png" height=30>
</div>
<div id="inhalt">

<h1>Room Finder</h1>


		<?php
					//make connection to server
					$link = mysql_connect('localhost', 'pott0180', 'ckersixt');
					if(!$link) {
						die('Could not connect: ' . mysql_error());
					}
				
					//select database
					$db_selected = mysql_select_db('soloono_roomFinder', $link);
					if (!$db_selected) {
						die('Cant use db soloono_roomFinder: ' . mysql_error());
					}
		
		
		  $Room_from=$_REQUEST['Room_from'];
		  $Building_from=$_REQUEST['Building_from'];
		
		  $building_result = sprintf("SELECT name FROM Building");
		  $building_query = mysql_query($building_result);
		
		  echo "<h3>Your Destination</h3>";
		  echo "Choose your destination Building and Room number.<br>";
			
		  //Create Form and populates it from database
		  echo '<form action="results.php" method="post">';
		  echo "<h4>Building: ";
		  echo '<select name="Building_to" id="building_to" onchange="getRooms(this.value)">';
		  while($building_array = mysql_fetch_array($building_query))
		    {
		    echo '<option value="'.$building_array["name"].'">'.$building_array["name"].'</option>';
		    }
		    //hidden values pass variables from previous page to next page
		  echo "<input type='hidden' value='".$Room_from."' name='Room_from' />";
		  echo "<input type='hidden' value='".$Building_from."' name='Building_from' />";
		  echo "</select></h4>";
		
		  //Populate second select from database from js 
		  echo "<div id='buildingDiv'>";
			// populated in updateRooms2.php
		  echo '</div>';
		  
		  echo '<INPUT TYPE="image" SRC="http://i1120.photobucket.com/albums/l499/mill4655/roomFinder/Next.png" width=90 height=28 ALT="Submit Form">  ';
         echo '<a href="index.php"><img SRC="http://i1120.photobucket.com/albums/l499/mill4655/roomFinder/BackButton.jpg" width=90 height =28  ALT="Back"></a>';
		  echo '</form>';
		
		  echo 'Location > <b>Destination</b> > Building Map > Floor Map<br>';		
		
		  echo "<br />For a full campus map, click <a href='http://www.d.umn.edu/maps/big_UMD_map.gif'>here</a><br />";
		  echo "For help, credits, more info, click <a href='about.html'>here</a><br>";		
		
		  mysql_close($link);
		
		
		 ?>

<br><br>

</div>
</body>
</html>